package wang.aweb.childcar.controller.api;

import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import wang.aweb.childcar.common.ApiRestResponse;
import wang.aweb.childcar.service.OrderService;

import java.util.Map;

@RestController
@RequestMapping("/api/play/")
public class PlayController {
    @Autowired
    private OrderService orderService;
    @ApiOperation("开始游玩")
    @PostMapping("start")
    public ApiRestResponse start(@RequestBody Map reqMap){
        String orderNo=orderService.doStart(reqMap.get("imei").toString());
        return ApiRestResponse.success(orderNo);
    }
    @ApiOperation("结束游玩")
    @PostMapping("end")
    public ApiRestResponse end(@RequestBody Map reqMap){
        String orderNo=reqMap.get("orderNo").toString();
        orderService.doEnd(orderNo);
        return ApiRestResponse.success();
    }
    @ApiOperation("发送信息")
    @PostMapping("sendCmd")
    public ApiRestResponse sendCmd(@RequestBody Map reqMap){
        String orderNo=reqMap.get("orderNo").toString();
        String cmd=reqMap.get("cmd").toString();
        orderService.sendCmd(orderNo,cmd);
        return ApiRestResponse.success();
    }
}
